using System.Configuration;
using IniParser;
using IniParser.Model;

namespace ColorMapSystem.Helper;


public class DeviceIniConfig
{
    public int X { get; set; }
    public int Y { get; set; }
    public int TmbHead { get; set; }
    public int TmbStart { get; set; }
}

public class IniConfigReader
{
    private static readonly string IniFilePath = Path.Combine(Directory.GetCurrentDirectory(), "Template","SJH.ini");

    public static DeviceIniConfig? GetDeviceConfig(string sectionName)
    {
        var parser = new FileIniDataParser();
        IniData data = parser.ReadFile(IniFilePath);

        if (!data.Sections.ContainsSection(sectionName))
            return null;

        var section = data[sectionName];

        return new DeviceIniConfig
        {
            X = int.Parse(section["X"]),
            Y = int.Parse(section["Y"]),
            TmbHead = int.Parse(section["TMB_head"]),
            TmbStart = int.Parse(section["TMB_start"]),
        };
    }
}